﻿<Window x:Class="TestApp.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:TestApp.Client"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        Title="Client"
        Height="500"
        Width="950">
    <Window.Resources>
        <c:ParamValueToColorConverter x:Key="ParamValueToBackgroundColorConverter" />

        <DataTemplate x:Key="NormalCellTemplate" DataType="{x:Type c:EntityParamViewModel}">
            <TextBlock 
                Text="{Binding Value, StringFormat={}{0:#,0.00}}" 
                Background="{Binding Value, Converter={StaticResource ParamValueToBackgroundColorConverter}}"
                Foreground="Red"/>
        </DataTemplate>

        <DataTemplate DataType="{x:Type c:Bootstraper}">
            <Grid DataContext="{Binding Entities}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <DataGrid
                    Grid.Row="0"
                    IsReadOnly="True"
                    ItemsSource="{Binding Entities}"
                    AutoGenerateColumns="False"
                    MinColumnWidth="40">
                    <i:Interaction.Behaviors>
                        <c:DataGridColumnsBehavior CellTemplate="{StaticResource NormalCellTemplate}"/>
                    </i:Interaction.Behaviors>
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Entity" Width="100" Binding="{Binding Name}"/>
                    </DataGrid.Columns>
                </DataGrid>
                <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="3">
                    <TextBlock VerticalAlignment="Center" Text="Totals type: "/>
                    <ComboBox ItemsSource="{Binding AllAggregates}" SelectedItem="{Binding SelectedAggregate}" MinWidth="100"/>
                    <TextBlock VerticalAlignment="Center" Text="Updates: " Margin="10, 0, 0, 0"/>
                    <TextBlock VerticalAlignment="Center" Text="{Binding UpdatesCount}" MinWidth="100"/>
                </StackPanel>
            </Grid>
        </DataTemplate>

    </Window.Resources>

    <c:Bootstraper/>

</Window>
